/**
 * @file    SensorEvents.h
 * @brief   Collects events (wosh::Fact extension) related to SensorLight and SensorMotion devices.
 *
 * @see     wosh::devices::SensorLight_LightChanged [wosh::interfaces::devices::SensorLight]
 * @see     wosh::devices::SensorMotion_MotionDetected [wosh::interfaces::devices::SensorMotion]
 ****************************************************************************
 * @version 0.8.462 $Id: SensorEvents.h 2891 2010-08-12 01:58:59Z alex $
 * @author  Alessandro Polo
 ****************************************************************************/
/* Copyright (c) 2007-2010, WOSH - Wide Open Smart Home 
 * by Alessandro Polo - OpenSmartHome.com
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the OpenSmartHome.com WOSH nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY Alessandro Polo ''AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL Alessandro Polo BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ****************************************************************************/

#ifndef __WOSH_Interfaces_Events_Sensors_H__
 #define __WOSH_Interfaces_Events_Sensors_H__

 #include <woshDefs.h>
 #include <core/Fact.h>
 #include <interfaces/devices/SensorLight.h>
 #include <interfaces/devices/SensorMotion.h>

 
namespace wosh {
 namespace devices {

 #define _SensorLight_EVENT_LightChanged		"LightChanged"

/**
 * @class   wosh::devices::SensorLight_LightChanged
 * @brief   Raised when connection state has been changed.
 *
 * Internally data is stored as a Variant[INT] (when previous state is not
 * available) or a List containing two Variant[INT] (second value stores
 * the previous connection state). 
 *
 * There are no additional fields, this is a wrapper class provided for convenience.
 *
 * @see     wosh::Fact
 * @see     wosh::interfaces::devices::SensorLight
 ****************************************************************************
 * @version 0.8.462 $Id: SensorEvents.h 2891 2010-08-12 01:58:59Z alex $
 * @author  Alessandro Polo
 ****************************************************************************/
class SensorLight_LightChanged : public wosh::Fact
 {
	WOSH_SERIALIZABLE(wosh::devices::SensorLight_LightChanged)

	public:
		/**
		 * @brief  Empty constructor.
		 */
		SensorLight_LightChanged()
			: wosh::Fact(_SensorLight_EVENT_LightChanged) { }
		/**
		 * @brief  Constructor with initializers.
		 * @param light_state [in] the new state of the connection
		 */
		SensorLight_LightChanged( wosh::interfaces::devices::SensorLight::LIGHT_STATE light_state );
		/**
		 * @brief  Constructor with initializers.
		 * @param light_state [in] the new state of the connection
		 * @param previous_light_state [in] the old (previous) state of the connection
		 */
		SensorLight_LightChanged( wosh::interfaces::devices::SensorLight::LIGHT_STATE light_state,
								 wosh::interfaces::devices::SensorLight::LIGHT_STATE previous_light_state );
		/**
		 * @brief  Copy constructor.
		 * @param m [in] the source object to be copied
		 */
		SensorLight_LightChanged( const SensorLight_LightChanged& m )
			: wosh::Fact(m) { }
		/**
		 * @brief  Empty destructor.
		 */
		virtual ~SensorLight_LightChanged() { }

	public:
		/**
		 * @brief   Get the new connection state.
		 * @return  integer value defined in wosh::interfaces::devices::SensorLight::LIGHT_STATE
		 */
		wosh::interfaces::devices::SensorLight::LIGHT_STATE getLightState() const;

		inline bool isBright() const		{ return ( (getLightState() & wosh::interfaces::devices::SensorLight::STATE_BRIGHT) == wosh::interfaces::devices::SensorLight::STATE_BRIGHT ); }
		inline bool isDark() const		{ return ( (getLightState() & wosh::interfaces::devices::SensorLight::STATE_DARK) == wosh::interfaces::devices::SensorLight::STATE_DARK ); }

		/**
		 * @brief   Get light state as a literal string
		 * @return  light state as literal string
		 */
		inline const char* getLightStateAsString() const {
			return wosh::interfaces::devices::SensorLight::getLightStateAsString( getLightState() );
		 }

		/**
		 * @brief   Get the previous connection state.
		 * @return  integer value defined in wosh::interfaces::devices::SensorLight::LIGHT_STATE
		 */
		wosh::interfaces::devices::SensorLight::LIGHT_STATE getPreviousLightState() const;

	public:
		/**
		 * @brief   Get a human friendly description of the event
		 * @return  string such as "SensorLight is Connected"
		 */
		virtual std::string toString() const;

}; // class def





 #define _SensorMotion_EVENT_MotionDetected		"MotionDetected"

/**
 * @class   wosh::devices::SensorMotion_MotionDetected
 * @brief   Raised when connection state has been changed.
 *
 * Internally data is stored as a Variant[INT] (when previous state is not
 * available) or a List containing two Variant[INT] (second value stores
 * the previous connection state). 
 *
 * There are no additional fields, this is a wrapper class provided for convenience.
 *
 * @see     wosh::Fact
 * @see     wosh::interfaces::devices::SensorMotion
 ****************************************************************************
 * @version 0.8.462 $Id: SensorEvents.h 2891 2010-08-12 01:58:59Z alex $
 * @author  Alessandro Polo
 ****************************************************************************/
class SensorMotion_MotionDetected : public wosh::Fact
 {
	WOSH_SERIALIZABLE(wosh::devices::SensorMotion_MotionDetected)

	public:
		/**
		 * @brief  Empty constructor.
		 */
		SensorMotion_MotionDetected()
			: wosh::Fact(_SensorMotion_EVENT_MotionDetected) { }
		/**
		 * @brief  Constructor with initializers.
		 * @param motion_state [in] the new state of the connection
		 */
		SensorMotion_MotionDetected( wosh::interfaces::devices::SensorMotion::MOTION_STATE motion_state );
		/**
		 * @brief  Constructor with initializers.
		 * @param motion_state [in] the new state of the connection
		 * @param previous_motion_state [in] the old (previous) state of the connection
		 */
		SensorMotion_MotionDetected( wosh::interfaces::devices::SensorMotion::MOTION_STATE motion_state,
								 wosh::interfaces::devices::SensorMotion::MOTION_STATE previous_motion_state );
		/**
		 * @brief  Copy constructor.
		 * @param m [in] the source object to be copied
		 */
		SensorMotion_MotionDetected( const SensorMotion_MotionDetected& m )
			: wosh::Fact(m) { }
		/**
		 * @brief  Empty destructor.
		 */
		virtual ~SensorMotion_MotionDetected() { }

	public:
		/**
		 * @brief   Get the new connection state.
		 * @return  integer value defined in wosh::interfaces::devices::SensorMotion::MOTION_STATE
		 */
		wosh::interfaces::devices::SensorMotion::MOTION_STATE getMotionState() const;

		inline bool isMotionDetected() const		{ return ( (getMotionState() & wosh::interfaces::devices::SensorMotion::STATE_MOTION_DETECTED) == wosh::interfaces::devices::SensorMotion::STATE_MOTION_DETECTED ); }
		inline bool isMotionNotDetected() const		{ return ( (getMotionState() & wosh::interfaces::devices::SensorMotion::STATE_MOTION_NONE) == wosh::interfaces::devices::SensorMotion::STATE_MOTION_NONE ); }

		/**
		 * @brief   Get light state as a literal string
		 * @return  light state as literal string
		 */
		inline const char* getMotionStateAsString() const {
			return wosh::interfaces::devices::SensorMotion::getMotionStateAsString( getMotionState() );
		 }

		/**
		 * @brief   Get the previous connection state.
		 * @return  integer value defined in wosh::interfaces::devices::SensorMotion::MOTION_STATE
		 */
		wosh::interfaces::devices::SensorMotion::MOTION_STATE getPreviousMotionState() const;

	public:
		/**
		 * @brief   Get a human friendly description of the event
		 * @return  string such as "Motion Detected"
		 */
		virtual std::string toString() const;

}; // class def





 }; // namespace devices
}; // namespace wosh


#endif //__WOSH_Interfaces_Events_Sensors_H__
